#!/usr/bin/env python
# -*- encoding:utf-8 -*-
#**
#-------------------------------------------------------------------------------
#[Subject   -- SQL_Gen]
#[Author    -- tianxu.xxf]
#[Created   -- 2010.9.19]
#[Updated   -- ]
#[UpAuthor  -- ]
#-----------------------------------------------------------------------------*#
from Condition import Condition
from Const._Operator import EQ,NEQ,LT,LE,GT,GE

def UDF(name):
    def tmpFunction(*parameters):
        return Function(name, *parameters)
    return tmpFunction

class Function:
    """"""

    def __init__(self,name='', *parameters):
        self.__name = name
        self.__parameters = list(parameters)
        self.__alias = ''

    def AS(self, alias):
        function = Function(self.__name)
        function._Function__parameters = self.__parameters
        function._Function__alias = alias
        return function

    def __eq__(self, item):
        return Condition(self,EQ,item)

    def __ne__(self, item):
        return Condition(self,NEQ,item)

    def __lt__(self, item):
        return Condition(self,LT,item)

    def __le__(self, item):
        return Condition(self,LE,item)

    def __gt__(self, item):
        return Condition(self,GT,item)

    def __ge__(self, item):
        return Condition(self,GE,item)
